import { onMounted, onUnmounted } from 'vue';

export default function useKeyboard(callback) {
    const handleKeydown = (event) => {
        callback(event.keyCode);
    };

    onMounted(() => {
        window.addEventListener('keydown', handleKeydown);
    });

    onUnmounted(() => {
        window.removeEventListener('keydown', handleKeydown);
    });
}